package com.baomidou.ant.utils;

import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class MyDateUtil {
    public static String dateCheck(LocalDateTime localDateTime){
//        String createTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss").format(localDateTime);
//        String nowTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss").format(LocalDateTime.now());
        Duration differenceValue = Duration.between(localDateTime ,LocalDateTime.now());
        long minutesTime = differenceValue .toHours();
        return Long.toString(minutesTime);
    }

    public static String dateCheckOfDay(String string){
        DateTimeFormatter DATEFORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDate ld = LocalDate.parse(string, DATEFORMATTER);
        LocalDateTime ldt = LocalDateTime.of(ld, LocalDateTime.now().toLocalTime());
//        String createTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss").format(localDateTime);
//        String nowTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss").format(LocalDateTime.now());
        Duration differenceValue = Duration.between(ldt ,LocalDateTime.now());
        long minutesTime = differenceValue .toDays();
        return Long.toString(minutesTime);
    }
}
